package org.graduates.webapp.actions.course;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.graduates.webapp.actions.BaseAction;
import org.projects.graduates.domain.HomeworkHandin;

/**
 * 给作业打分
 * 
 * @author Administrator
 * 
 */
@Action(results = { @Result(name = "success", type = "json"), @Result(name = "input", type = "json") })
public class ScoreHomeworkAction extends BaseAction {

	private static final long serialVersionUID = 1898299596872373447L;

	private int score = 1;

	private long handid = 0L;

	private boolean success = false;

	public String execute() {

		if (0L == handid) {
			return INPUT;
		}

		HomeworkHandin handin = HomeworkHandin.get(HomeworkHandin.class, handid);

		if (null == handin) {
			return INPUT;
		}
		System.out.println("\n\n id:" + handid); 
		this.gradApplication.scoreHomeworkHandin(handin, score, getCurrentPerson());

		success = true;

		return SUCCESS;
	}

	public int getScore() {
		return score;
	}

	public void setScore(int score) {
		this.score = score;
	}

	public long getHandid() {
		return handid;
	}

	public void setHandid(long handid) {
		this.handid = handid;
	}

	public boolean isSuccess() {
		return success;
	}

}
